package ru.cod.rs.exmpls.main.interfaces.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import ru.cod.rs.exmpls.main.interfaces.FileIO;
import android.content.res.AssetManager;
import android.os.Environment;

public class FileIOImpl implements FileIO {
	AssetManager assetManager;
	String exStoragePath;

	public FileIOImpl(AssetManager asManager) {
		assetManager = asManager;
		exStoragePath = Environment.getExternalStorageDirectory()
				.getAbsolutePath() + File.separator;
	}

	@Override
	public InputStream readAsset(String fileName) throws IOException {
		return assetManager.open(fileName);
	}

	@Override
	public InputStream readFile(String fileName) throws IOException {
		return new FileInputStream(exStoragePath + fileName);
	}

	@Override
	public OutputStream writeFile(String fileName) throws IOException {

		return new FileOutputStream(exStoragePath + fileName);
	}

}
